package com.jack.code;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by zhang_j on 2019/10/21
 */
public class App {

    private static final Logger log = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) throws Exception{
        ZooKeeper zk = new ZooKeeper("localhost:2181", 3000, new Watcher() {
            public void process(WatchedEvent event) {
                log.info(event.toString());
            }
        });

        Stat e = zk.exists("/logs",null);
        System.out.println(e);
        log.info("exist "+ e);

        zk.setData("/logs","Data of node 3".getBytes(),-1);
    }
}
